<?php require_once 'header.php';?>    
<!-- DataTables Responsive CSS -->
    <link href="sb2/vendor/datatables-responsive/dataTables.responsive.css" rel="stylesheet">

        <!-- Page Content -->
        <div id="page-wrapper">
            <div class="container-fluid">
                <div class="row">
                <div class="col-lg-12">
                    <div class="panel panel-default">
                        <div class="panel-heading">
                            <?php echo XXF_LNAME?> <table><tr><td>专项培训上传 <a href="pxy/type/downzxpxtemp" target="_blank">模板</a>=></td><td><input type="file" id="zxpx"></td></tr></table>
                        </div>
                        <!-- /.panel-heading -->
                        <div class="panel-body">
                            <table width="100%" class="table table-striped table-bordered table-hover" id="dataTables-example">
                                <thead>
                                    <tr>
                                        <th>序号</th>
                                        <th>班级名称</th>
                                        <th>人数</th>
                                        <th>课程</th>
                                        <th>时间</th>
                                        <th>班主任</th>
                                        <th>操作</th>
                                    </tr>
                                </thead>
                                <tbody>
                                	<?php
                                	$i=0;
                                	foreach ($result as $row){$i++;
                                	?>
                                    <tr class="<?php echo $i%2==0?"even":"odd";?> gradeA <?php echo ((date("Y-m-d")>$row['stime'])&&(date("Y-m-d")<$row['etime']))?("success"):""?>" id='<?php echo $row['pid'];?>'>
                                    	<td><?php echo $i;?></td>
                                        <td><a href="pxy_list/pid/<?php echo $row['pid']?>"><?php echo $row['pname'];?></a></td>
                                        <td><?php echo xdb::getInstance()->getvar("select count(1) from peixunxueyuan where pid=".$row['pid']);?></td>
                                    	<td>
                                    	<?php 
                                    	   $pjk=xdb::getInstance()->getvar("select count(1) from peixun_jk as jk,peixunjiaoshi as j,peixunkecheng as k where jk.pjid=j.id and jk.pkid=k.id and jk.pid=".$row['pid']);
                                    	   echo $pjk;
                                    	?>
                                    	</td>
                                    	<td><?php echo $row['shiqi']."[".substr($row['stime'],5,5).":".substr($row['etime'],5,5)."]";?></td>
                                        <td><?php echo $row['realname'];?></td>
                                        <td>
                                        	<a href="pxy_bm/pid/<?php echo $row['pid']?>" target="_blank">报名</a> |
                                        	<a href="pxy_kc/pid/<?php echo $row['pid']?>">课程</a>
                                        </td>
                                    </tr>
                                	<?php 
                                	}
                                	?>
                                </tbody>
                            </table>
                        </div>
                        <!-- /.panel-body -->
                    </div>
                    <!-- /.panel -->
                </div>
                <!-- /.col-lg-12 -->
            </div>
            <!-- /.row -->
             </div>
        </div>
        <!-- /#page-wrapper -->
  </div>
        <!-- DataTables JavaScript -->
<?php require_once 'bottom.php';?>
    <script src="sb2/vendor/datatables/js/jquery.dataTables.js"></script>
    <script src="sb2/vendor/datatables-plugins/dataTables.bootstrap.min.js"></script>
    <script src="sb2/vendor/datatables-responsive/dataTables.responsive.js"></script>
    <script>
    $(document).ready(function() {
        $('#dataTables-example').DataTable({
            responsive: true,
            "aaSorting": [[ 0, "desc" ]],
            "aLengthMenu": [ 200, 100, 50, 10 ]
        });
    });

	$("#zxpx").xxfile({
		url:"pxy",
		accept:".xls",
		data:{
			type:"upzxpx"//专项培训
		}
		//,success:function(data){$.xalert(data);}
	});
    
    function del(pid){
		$.xconfirm("删除后无法恢复，确定要删除此条记录么？",function(data){
 			if(data){
				$.xloading(1);
				$.post($.gu("peixunbanadd"),{type:'del',pid:pid},function(data1){
					if(data1==0){
						$.xloading(0);
						$.xalert("删除失败");
					}else{
						window.location.reload();
					}
				}); 
			} 
		});
    }
    function add(){
		var shiqi=$("#shiqi").val();
 		var bzrid=$("#bzrid").val();
 		var pname=$("#pname").val();
 		if(shiqi=="0"||bzrid=="0"||pname.length<1){
			$.xalert("请将信息填写完整！");return false;
 	 	}
    	$.xconfirm("确定添加？",function(data){
 			if(data){
				$.xloading(1);
				$.post($.gu("peixunbanadd"),{type:'add',shiqi:shiqi,bzrid:bzrid,pname:pname,uid:<?php echo XXF_UID?>},function(data1){
					if(data1==0){
						$.xloading(0);
						$.xalert("添加失败");
					}else{
						window.location.reload();
					}
				}); 
			} 
		});
    }    
    </script>